/*******************************************************
> Copyright (C) 2024 ==IOT== All rights reserved.
> File Name: ref.cpp
> Author: IOT
> Website:www.slq.org
> Created Time: 2024年10月17日 星期四 15时23分52秒
***************************************************/

#include <iostream>

using namespace std;

void swap_num(int &x, int &y);
void swap_num(int *px, int *py);

int main(int argc,const char* argv[])
{
	int n = 3;
	int * pn = &n;
	float array[10];

	//float & rarray[10] = array;

	int a = 10;
	int *pa = &a;
	int &ra = a; // 对变量a起别名为ra

	cout << "a = " << a << endl;
	cout << "a = " << *pa << endl;
	cout << "a = " << ra << endl;


	float f;
	float &rf = f;
	int * &rpn = pn;
	cout << "n = " << n << endl;
	cout << "n = " << *pn << endl;
	cout << "n = " << *rpn << endl;

	int x,y;
	x = 10;
	y = 20;

	//swap_num(x, y);
	swap_num(&x, &y);

	cout << "x = " << x << ", y = " << y << endl;
    return 0;
}

void swap_num(int *px, int *py)
{
	int t;
	t = px[0];
	*px = *py;
	*py = t;
}

void swap_num(int &rx, int &ry)
{
	int t;
	t = rx;
	rx = ry;
	ry = t;
}

